package com.kevin.list;

/**
 * @Author LXL
 * @Date 2020/9/24 10:00
 **/
public class Person {
    private Integer age;
    private String name;

    public Person(Integer age, String name){
        this.age = age;
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) return false;

        if (obj instanceof  Person){
            Person person = (Person) obj;
            return person.getName().equals(this.name);
        }
        return false;
    }

    @Override
    protected void finalize() throws Throwable {
        super.finalize();
        System.out.println("Person -- finalize ");
    }
}
